#include<iostream>
#include<vector>
#include<cstdlib>
#include<queue>
#include<unordered_map>
#include<map>
using namespace std;

int inf = 1000000007;
vector<int> arr;
unordered_map<int, int> l, r;

long long dfs(int pos, int pre, vector<vector<int>>& dp, vector<vector<bool>>& flag)
{
	if (!pos) return 1;
	if (!pre) return 0;
	if (flag[pos][pre]) return dp[pos][pre];
	long long ans = 0;
	ans = dfs(pos, pre - 1, dp, flag) + dfs(l[pos], pre - 1, dp, flag) * dfs(r[pos], pre, dp, flag);
	ans %= inf;
	flag[pos][pre] = 1;
	return dp[pos][pre] = ans;
}

void solve()
{
	int n, m; cin >> n >> m;
	arr.push_back(0);
	for (int i = 1; i <= n; i++)
	{
		int temp; cin >> temp;
		arr.push_back(temp);
	}
	deque<pair<int, int>> que;
	que.push_back(pair<int, int>(1, arr[1]));
	for (int i = 2; i <= n; i++)
	{
		int pre = 0;
		while (!que.empty() && que.back().second < arr[i])
		{
			pre = que.back().first;
			que.pop_back();
		}
		l[i] = pre;
		if (!que.empty()) r[que.back().first] = i;
		que.push_back(pair<int, int>(i, arr[i]));
	}
	vector<vector<int>> dp(n + 5, vector<int>(m + 5, 0));
	vector<vector<bool>> flag(n + 5, vector<bool>(m + 5, 0));
	cout << dfs(que.front().first, m, dp, flag) << endl;
	arr.clear();
	l.clear();
	r.clear();
}

int main()
{
	int t; cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}